﻿@*@model IList<XCode.Membership.VisitStat>*@
@using NewLife;
@using NewLife.Web;
@using XCode;
@using XCode.Configuration;
@{
    var fact = ViewBag.Factory as IEntityOperate;
    var page = ViewBag.Page as Pager;
    var fields = ViewBag.Fields as IList<FieldItem>;
        var set = ViewBag.PageSetting as PageSetting;

    /* var level = (XCode.Statistics.StatLevels)page["Level"].ToInt();*/
}
<table class="table table-bordered table-hover table-striped table-condensed">
    <thead>
        <tr>
            @if (set.EnableSelect)
            {
                <th class="text-center" style="width:10px;"><input type="checkbox" id="chkAll" title="全选" /></th>
            }
            <th class="text-center hidden-md hidden-sm hidden-xs"><a href="@Html.Raw(page.GetSortUrl("ID"))">编号</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Time"))">时间</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Page"))">页面</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Title"))">标题</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Times"))">次数</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Users"))">用户</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("IPs"))">IP</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Error"))">错误</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Cost"))">平均耗时</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("MaxCost"))">最大耗时</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("CreateTime"))">创建时间</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("UpdateTime"))">更新时间</a></th>
            @if (this.Has(PermissionFlags.Detail, PermissionFlags.Update, PermissionFlags.Delete))
            {
                <th class="text-center">操作</th>
            }
        </tr>
    </thead>
    <tbody>
        @foreach (var entity in Model)
        {
            //var st = new VisitStatModel
            //{
            //    Level = level,
            //    Time = entity.Time
            //};
            <tr>
                @if (set.EnableSelect)
                {
                    <td class="text-center"><input type="checkbox" name="keys" value="@entity.ID" /></td>
                }
                <td class="text-center hidden-md hidden-sm hidden-xs">@entity.ID</td>
                @*<td class="text-right">@st</td>*@
                <td>@entity.Page</td>
                <td>@entity.Title</td>
                <td class="text-right">@entity.Times.ToString("n0")</td>
                <td class="text-right">@entity.Users.ToString("n0")</td>
                <td class="text-right">@entity.IPs.ToString("n0")</td>
                <td class="text-right">@entity.Error.ToString("n0")</td>
                <td class="text-right">@entity.Cost.ToString("n0") ms</td>
                <td class="text-right">@entity.MaxCost.ToString("n0") ms</td>
                <td>@entity.CreateTime.ToFullString("")</td>
                <td>@entity.UpdateTime.ToFullString("")</td>
                @if (this.Has(PermissionFlags.Detail, PermissionFlags.Update, PermissionFlags.Delete))
                {
                    <td class="text-center">
                        @Html.PartialAsync("_List_Data_Action", (Object)entity).Result
                    </td>
                }
            </tr>
        }
    </tbody>
</table>